package com.code.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * 开启异步调用注解
 *
 * @author wangjie
 * @version V1.0
 * @date 2020/2/22
 */
@Service
public class AsyncService {

    Logger logger = LoggerFactory.getLogger(getClass());


    //告诉Spring这是一个异步方法
    @Async
    public void hello(){
        try {
            logger.info("【异步注解测试--处理数据中】");
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        logger.info("【异步注解测试--处理数据结束】");

    }
}
